//
//  PKLocationUtils.swift
//  Panku
//
//  Created by mac on 2017/2/17.
//  Copyright © 2017年 Monster. All rights reserved.
//

import UIKit
import ReactiveCocoa
import ReactiveSwift
import Result

class PKLocationUtils: NSObject {
    
    //获取当前城市
//    func currentCity(callback:@escaping (_ city:String?)->Void) -> Void{
//        SGLocation.share().getCity = callback
//    }
    
    class func currentCity() -> SignalProducer<String,NoError>{
        let signalProducer = SignalProducer<String,NoError> { (observer, disposable) in
            SGLocation.share().getCity = { (location) in
                
                if location != nil && location != ""{
                    observer.send(value: location!)
                    observer.sendCompleted()
                }else{
                    observer.send(value: "未知")
                    observer.sendCompleted()
                }
            }
        
        }
        
        return signalProducer
    }
}
